﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SocketLib
{
	class MessageCommand
	{
		private string _version;
		private string _packageId;
		private string _sender;
		private string _host;
		private long _commandString;
		private string _meno;

		public MessageCommand()
		{
		}
		public MessageCommand(string strComand)
		{

		}

		/// <summary>
		/// 版本号
		/// </summary>
		public string Version
		{
			get { return _version; }
			set { _version = value; }
		}
		/// <summary>
		/// 包编号
		/// </summary>
		public string PackageId
		{
			get { return _packageId; }
			set { _packageId = value; }
		}
		/// <summary>
		/// 发送人名字
		/// </summary>
		public string Sender
		{
			get { return _sender; }
			set { _sender = value; }
		}
		/// <summary>
		/// 发送主机名
		/// </summary>
		public string Host
		{
			get { return _host; }
			set { _host = value; }
		}
		/// <summary>
		/// 命令字
		/// </summary>
		public long CommandString
		{
			get { return _commandString; }
			set { _commandString = value; }
		}
		/// <summary>
		/// 附加信息
		/// </summary>
		public string Meno
		{
			get { return _meno; }
			set { _meno = value; }
		}

		public void SetCommand(string strMessage)
		{
			string[] s = strMessage.Split(':');

			try
			{
				_version = s[0];
			}
			catch
			{ }

			try
			{
				_packageId = s[1];
			}
			catch { }

			try
			{
				_sender = s[2];
			}
			catch { }
			try
			{
				_host = s[3];
			}
			catch { }
			try
			{

				_commandString = long.Parse(s[4]);
			}
			catch { }
			try
			{
				_meno = s[5];
			}
			catch { }
		}
	}

}
